import java.util.Date;

import data.dao.DBManager;
import data.dao.IEventDAO;
import data.dao.ITruckDAO;;
import data.model.Truck;
import data.model.Event;

import data.mediator.DBMediator;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Test {

    public Test(){}

    public void test1(){
	System.out.println("Debut du test de pilote JDBC........");

	try{
	System.out.println("Connection.........");
	Class.forName("org.sqlite.JDBC");
	System.out.println("   Driver: OK");
	Connection c = DriverManager.getConnection("jdbc:sqlite:test.sqlite");
	System.out.println("   DB: OK");
	c.setAutoCommit(true);	
	Statement stmt = null;
	stmt = c.createStatement();
	}catch ( Exception e ) {
	    System.err.println( e.getClass().getName() + ": " + e.getMessage() );
	    System.exit(0);
	}
    }

  
    public void test2(){
	System.out.println("\n\nDebut du test #2........");
	DBManager DB = new DBManager();
	System.out.println("   Instanciation d'un DBManager: OK");
    }
    

    public void test3(){
	System.out.println("Debut du test #3........");

	//DBManager DB = new DBManager();
	
	Truck T1 = new Truck(11, 12, 11, 8, 7, 2);
	
	Truck T2 = new Truck(2, 12, 11, 8, 7, 2);	
	System.out.println("   Instanciation: OK");

	if(DBMediator.addOrModifyTruck(T1))
	    System.out.println("   ADD: OK");
	else
	    System.out.println("   ADD: NO");
	
	DBMediator.addOrModifyTruck(T2);
		
	Truck test = DBMediator.getTruck(2);
	System.out.println("   get: OK");
    }

    public void test4(){
	System.out.println("Debut du test #4........");
	
	Date  D1 = new Date();
	Date  D2 = new Date();
	Event E1 = new Event("Test1", 12, 11, 123, D1, D2);
	Event E2 = new Event("test2", 13, 12, 10, D1, D2);
	
	DBMediator.addOrModify(E1);
    }

    public static void main(String[] args){
	
	test4();



	
	
    }
}
